export const LocalStorage = {
  set(name, obj) {
    localStorage.setItem(name, typeof obj === 'object' ? JSON.stringify(obj) : obj)
  },

  get(name) {
    const obj = localStorage.getItem(name)

    if (obj && (obj.trim().startsWith('[') || obj.trim().startsWith('{'))) return JSON.parse(obj)

    return obj
  }
}

export const SessionStorage = {
  set(name, obj) {
    sessionStorage.setItem(name, typeof obj === 'object' ? JSON.stringify(obj) : obj)
  },

  get(name) {
    const obj = sessionStorage.getItem(name)

    if (obj && (obj.trim().startsWith('[') || obj.trim().startsWith('{'))) return JSON.parse(obj)

    return obj
  }
}
